﻿#ifndef DEVICECHARTSTAB_H
#define DEVICECHARTSTAB_H

#include <QDockWidget>
#include <QChart>
#include <QtCharts/QLineSeries>
#include <QScatterSeries>
#include <QDateTimeAxis>
#include <QChartView>
#include <QValueAxis>
#include "SendMessage/confirmdevice.h"
#include "deviceconfigtab.h"

QT_CHARTS_USE_NAMESPACE

namespace Ui {
class DeviceChartsTSC;
}
class QTableWidget;
class QLabel;
class QVBoxLayout;
class QHBoxLayout;
class QPushButton;
class QTimer;
class QTableWidgetItem;

class DeviceChartsTSC : public QDockWidget
{
    Q_OBJECT

public:
    explicit DeviceChartsTSC(QWidget *parent = nullptr);
    ~DeviceChartsTSC();
    QPushButton* m_start_rotate;
private:
    Ui::DeviceChartsTSC *ui;
    QChart* m_chart;
    QLineSeries* m_dseries_Temperature;
    QScatterSeries* m_scatterSeries_T;
    QDateTimeAxis* m_Time_daxisX;
    QValueAxis* daxisY_Temperature;
    QChartView* dchartView;
    QTableWidget* m_Bottom_TableWidget;
    QLabel* m_Label_Sample_Count;
    QLabel* m_Sample_Time;
    int m_Sanple_count = 0;
    bool startSampleFlag = true;
    QTimer* timerHeart;
    ConfirmDevice* confirmDevice;
    DeviceConfigTab* deviceConfigTab;
    QVBoxLayout* m_vLayout;
    QWidget* m_Right_Bottom;
    QHBoxLayout* m_hLayout;
    bool m_bFirstSampling = true;
    double m_dMaxT;
    double m_dMinT;
    QString m_currDatetime;
    bool m_isFirst_Simple = true;
    QTableWidgetItem* m_New_Value_Tem=nullptr;
    void set_Bottom_Charts_back();
private slots:
    void setOnceSampleDataChart(QByteArray data);
    void setIsEnableRotateButton(bool);
public slots:
    void recvComPullOut(QString& portName);
signals:
    void sendSampleEnable(bool);
};


#define DeviceChartsTSCRelease Singleton<DeviceChartsTSC>::Release()
#define DeviceChartsTSCInstance Singleton<DeviceChartsTSC>::GetInstance()

#endif // DEVICECHARTSTAB_H
